package sectorCrack.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import sectorCrack.bean.JobConfig;

public class PropertyManager {

	public static JobConfig loadProperty(InputStream file) {
		JobConfig jobConf = new JobConfig();
		Properties prop = new Properties();
		try {
			prop.load(file);
		} catch (IOException e) {
			e.printStackTrace();
		}

		if (prop.getProperty("SNR_THRESHOLD") != null) {
			jobConf.setSnrThreshold(Integer.parseInt(prop.getProperty("SNR_THRESHOLD")));
		}
		if (prop.getProperty("VEL_THRESHOLD") != null) {
			jobConf.setVelThreshold(Integer.parseInt(prop.getProperty("VEL_THRESHOLD")));
		}
		if (prop.getProperty("PREV_COEFF") != null) {
			jobConf.setPrevCoeff(Float.parseFloat(prop.getProperty("PREV_COEFF")));
		}
		if (prop.getProperty("CURRENT_COEFF") != null) {
			jobConf.setCurrCoeff(Float.parseFloat(prop.getProperty("CURRENT_COEFF")));
		}
		if (prop.getProperty("INPUT_PATH") != null) {
			jobConf.setInputPath(prop.getProperty("INPUT_PATH").trim());
		}
		if (prop.getProperty("OUTPUT_PATH") != null) {
			jobConf.setOutputPath(prop.getProperty("OUTPUT_PATH").trim());
		}
		return jobConf;
	}
}
